#include <string>
#include <iostream>
using namespace std;

class Entity
{
	private:
		int resist;
		int attack;
		int magic;
		int defense;
		int health;
		LPCSTR playerName;

		int attackDamage;
		int armorLevel;
		int magicDamage;
		int resistLevel;
		bool crit;
	
	public:
		int getDefense(){ return defense;}
		int getResist(){ return resist;}
		int getAttack(){ return attack;}
		int getMagic(){ return magic;}
		int getHealth(){ return health;}
		bool getCrit(){ return crit;}
		int getAttackDamage(){return attackDamage; }
		int getMagicDamage(){return magicDamage; }
		int getArmorLevel(){ return attackDamage; }
		int getResistLevel(){ return resistLevel; }
		LPCSTR getPlayer(){ return playerName;}

		void setStats(LPCSTR name, int hp, int atk, int def, int mgc, int res);
		void meleeAttack();
		void meleeDefense();
		void magicResist();
		void magicAttack();
		void minusHp(int damage){ health -= damage;}

};

class Alliance: public Entity{};
class Horde: public Entity{};


//Entity Functions
void Entity::setStats(LPCSTR name, int hp, int atk, int def, int mgc, int res)
{
	playerName = name;
	health = hp;
	attack = atk;
	defense = def;
	magic = mgc;
	resist = res;
}

void Entity::meleeAttack()
{
	attackDamage = 0;
	int roll = 0;
	crit = false;
	for (int x = 0; x < attack; x++)
		{
			roll = rand() % 10 + 1;
			if (roll == 10)
			{
				crit = true;
			}
			if (roll >= 4)
				attackDamage++;
		}
	if (crit == true)
		attackDamage++;
}

void Entity::meleeDefense()
{ 
	int roll = 0;
	armorLevel = 0;
	for (int x = 0; x < defense; x++)
	{
		roll = rand() % 10 + 1;
		if (roll >= 4)
			armorLevel++;
	}
}


void Entity::magicResist()
{
	int roll = 0;
	resistLevel = 0;
	for (int x = 0; x < resist; x++)
	{
		roll = rand()% 10 + 1;
		if(roll >= 4)
			resistLevel++;
	}
}

void Entity::magicAttack()
{
	int roll = 0;
	magicDamage = 0;
	crit = false;
	for (int x = 0; x < magic; x++)
		{
			roll = rand() % 10 + 1;
			if (roll == 10)
				crit = true;
			if (roll >= 4)
				magicDamage++;
		}
	if (crit == true)
		magicDamage++;
	
}